home *** CD-ROM | disk | FTP | other *** search
- // the implementation of class CAptCommonDialog
- // Copyright (C) 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
-
- #include "../stdafx.h"
-
- #include "../kbandef.h"
-
- #include "aptcmn.h"
-
- BEGIN_MESSAGE_MAP(CAptCommonDialog, CDialog)
- ON_LBN_DBLCLK (IDC_EXISTING, OnDblClk )
- ON_LBN_SELCHANGE(IDC_EXISTING, OnSelChange)
- ON_BN_CLICKED (IDC_PURGE , OnPurge )
- END_MESSAGE_MAP()
-
- CAptCommonDialog::CAptCommonDialog(
- CWnd* pParentWnd,
- uint nID,
- const APT_TABLE& apt_table,
- const APT_TABLE& apt_table_purged,
- const APERTURE& prev
- )
- : CDialog(nID, pParentWnd),
- m_apt_table (apt_table),
- m_apt_table_purged(apt_table_purged),
- m_prev (prev)
- {
- }
-
- CListBox& CAptCommonDialog::ctlExisting(void)
- {
- return *(CListBox*)GetDlgItem(IDC_EXISTING);
- }
-
- void CAptCommonDialog::SetTextInt(CEdit* pEdit, int value)
- {
- char str[50];
- sprintf(str, "%d", value);
- pEdit->SetWindowText(str);
- }
-
- void CAptCommonDialog::OnSelChange(void)
- {
- int sel = ctlExisting().GetCurSel();
- SetAll(m_apt_table[sel]);
- }
-
- void CAptCommonDialog::OnDblClk(void)
- {
- OnSelChange();
- OnOK();
- }
-
- int CAptCommonDialog::unit_change_micron2kban(int micron)
- {
- return micron * DIS_MICRON;
- }
-
- void CAptCommonDialog::DeleteAllItems(void)
- {
- for(uint i = 0; i < m_apt_table.size(); i++) {
- ctlExisting().DeleteString(0);
- }
- }
-
- void CAptCommonDialog::RegisterAllItems(void)
- {
- for(uint i = 0; i < m_apt_table.size(); i++) {
- const APERTURE& current = m_apt_table[i];
- AddAperture(current);
- if(current == m_prev) {
- m_index = i;
- }
- }
- }
-
- void CAptCommonDialog::OnPurge(void)
- {
- if(m_apt_table_purged.size() == 0) {
- MessageBeep(0);
- } else {
- DeleteAllItems();
- m_index = 0;
- m_apt_table = m_apt_table_purged;
- RegisterAllItems();
- if(m_apt_table.size() != 0) {
- SetAll(m_apt_table[m_index]);
- ctlExisting().SetCurSel(m_index);
- }
- }
- }
-